package com.yonyou.cyxdms.basedata.service.controller.series;

import com.yonyou.cyx.framework.controller.base.BaseController;
import com.yonyou.cyxdms.basedata.client.domains.vo.SeriesCacheVO;
import com.yonyou.cyxdms.basedata.service.service.series.SeriesService;
import com.yonyou.cyxdms.basedata.service.vo.CarserialDetailsVO;
import com.yonyou.cyxdms.basedata.service.vo.CarserialInfoVO;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 车系
 *
 * @author renwd
 * @since 2018/12/10
 */
@Api(tags = "车系相关接口")
@RestController
@RequestMapping("/series")
public class SeriesController extends BaseController {

    @Autowired
    private SeriesService seriesService;


    //日志对象
    public static final Logger logger = LoggerFactory.getLogger(SeriesController.class);

    /**
     * 按条件查询车系信息
     *
     * @param queryParam
     * @return java.util.List<com.yonyou.cyxdms.basedata.client.domains.DTO.basedata.SeriesCacheVO>
     * @author renwd
     * @since 2018/12/10
     */
    @GetMapping(value="/querySeriesByCondition")
    public List<SeriesCacheVO> querySeriesByCondition(@RequestParam Map<String, Object> queryParam) {
        return seriesService.querySeriesByCondition(queryParam);
    }

    /**
     * 根据品牌Id查询车系信息
     *
     * @param brandId
     * @return java.util.List<com.yonyou.cyxdms.basedata.client.domains.DTO.basedata.SeriesCacheVO>
     * @author guorp
     * @since 2018/12/13
     */
    @GetMapping(value = "/getSeriesByBrandId")
    public List<SeriesCacheVO> getSeriesByBrandId(@RequestParam Long brandId){
        return seriesService.getSeriesByBrandId(brandId);
    }

    /**
     * @description：根据车系名称模糊查询
     * @author     ：quankk
     * @date       ：Created in 2019/1/15 11:04
     * @modified By：
     */
    @GetMapping(value = "/seriesBySeriesName")
    public List<SeriesCacheVO> seriesBySeriesName(@RequestParam String appId, @RequestParam String seriesName){
        return seriesService.seriesBySeriesName(appId, seriesName);
    }

    /**
     * @description：查询所有车系
     * @author     ：quankk
     * @date       ：Created in 2019/1/15 15:22
     * @modified By：
     */
    @ApiOperation(value = "查询所有车系", notes = "查询所有车系")
    @GetMapping(value = "/allSeries", produces = "application/json")
    @ApiImplicitParams({@ApiImplicitParam(name = "userId", required = true, dataType = "string", paramType = "header", value = "用户")})
    public List<SeriesCacheVO> allSeries(){
        return seriesService.allSeries();
    }


    /**
     *  根据品牌ID查询车系列表信息
     *
     * @author dengqiang
     * @since 2019/1/2
     */

    @GetMapping(value = "/carserialList", produces = {"application/json;charset=UTF-8"})
    @ApiOperation(notes = "车系列表信息", value = "车系列表信息")
    public List<CarserialInfoVO> queryCarserialInfo(@ApiParam(name = "brandId", value = "品牌ID", required = true) @RequestParam(value = "brandId", required = false) String brandId) {

        logger.info("brandId:{}", brandId);

        return seriesService.queryCarserialInfo(brandId);

    }

    /**
     *  根据车系ID查询车系详情
     *
     * @author dengqiang
     * @since 2019/1/2
     */
    @GetMapping(value = "/queryCarserial", produces = {"application/json;" +
            "charset=UTF-8"})
    @ApiOperation(notes = "车系详情", value = "车系详情")
    public CarserialDetailsVO queryCarserialDetails(@ApiParam(name = "carserialId", value = "车系ID", required = true)@RequestParam(value = "carserialId", required =
            true) Long carserialId) {
        return seriesService.queryCarserialDetails(carserialId);
    }

    /**长城映射数据
     * @param:
     * @return:
     * @auther: tanjie
     * @since: 2019/9/10
     */
    @GetMapping(value = "/queryCarSerialByAppidAndName")
    public Long queryCarserialByAppidAndName(@RequestParam("appId") String appId,
                                             @RequestParam("serialName") String serialName) {
        return seriesService.queryCarserialByAppidAndName(appId, serialName);
    }

    /**查找code与id映射
     * @param:
     * @return:
     * @auther: tanjie
     * @since: 2019/9/10
     */
    @GetMapping("/querySeriesMapping")
    public Map<Long, String> querySeriesMapping(@RequestParam("appId") String appId) {
        return seriesService.querySeriesMapping(appId);
    }

    /**
     * @param:
     * @return:
     * @auther: tanjie
     * @since: 2019/11/4
     */
    @GetMapping("/getAllSeriesByAppId")
    public List<SeriesCacheVO> getAllSeriesByAppId(@RequestParam("appId") String appId) {
        return seriesService.getAllSeriesByAppId(appId);
    }
}
